<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>修改角色 </title>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/script/lib/jquery-1.5.1.js"></script>
<script type="text/javascript">
$(function(){
	<% if(request.getAttribute("updateMsg") != null){
		%>var updateMsg = eval('('+'<%=request.getAttribute("updateMsg")%>'+')');
			alert(updateMsg.msg);
		 if(updateMsg.close=='true'){
			parent.ClosePop();
		} 
	<%}else{%>
	$.ajax({
        type: 'POST',
        url: 'rolerule',
        dataType: 'json',
        success : function(data) {
		    var datas = eval('('+data+')');
	    	var obj = document.getElementById('rolerule');;
		    for(var i=0;i<datas.length;i++){
		    	var temp = datas[i];
		    	var opn = document.createElement("OPTION");
		        obj.appendChild(opn);
		        opn.innerHTML = temp.value;
		        opn.value = temp.code;
		    }
		    $.ajax({
		        type: 'POST',
		        url: 'getRole?roleid='+$("#roleid").val(),
		        dataType: 'json',
		        success : function(data) {
				    var role = eval('('+data+')');
				    $("#rolename").val(role.rolename);
				    $("#rolerule").val(role.rolerule);
				},
				error: function(data) { alert('获取管理角色异常'); }
		    });
		},
		error: function(data) { alert('获取管理员角色类型异常'); }
    });
<%}%>
	
});
function quitWin(){
	parent.ClosePop();
}
function submitForm(){
	if(!($("#rolename").val()) || $("#rolename").val() ==''){
		$("#nameMsg")[0].innerHTML = '*请输入管理员名称';
		return false;
	}
	if(!($("#rolerule").val()) || $("#rolerule").val() =='-1'){
		$("#typeMsg")[0].innerHTML = '*请选择角色类型';
		return false;
	}
}
</script>
</head>
<body>
	<div id="currentPossition" style="vertical-align: center">
		<table style="table-layout: fixed;" cellpadding="0" cellspacing="1" border="0">
		<tr><td><img width="7" height="7"  src="images/title/title-icon.gif" border="0" hspace="8" complete="complete"/></td>
		<td style="font-size: 9pt;">当前位置：系统管理>角色管理>修改角色</td></tr></table>
	</div>
	<div align="left" style="border-color: #7f9db9;border-width: 1px;border-style: solid; margin-top: 6px;" >
		<div align="center" style="height:300px;width:100%;background-color:#f1f5ff;">
			<div align="left" style="height:25px;width:100%;background-color:#d5e2f2;font-size: 12px;vertical-align: ">
				<table style="vertical-align: middle;height: 100%;"><tr><td><img width="7" height="7"  src="images/title/title-icon.gif" border="0" hspace="8" complete="complete"/>修改角色信息</td></tr></table>
			</div>
			<form action="updateRole" onSubmit="return submitForm()">
				<table style="width: 100%;">
					<tr >
						<td style="height:50px;font-size: 12px;width:35%;" align="right"><font color="red"> 角色名称：</font></td>
						<td style="width:45%;" align="left"><input type="text" name="rolename" id="rolename" value="" style="width: 100%" />
						</td>
						<td style="width:20%;" align="left"><font color="red" > <div id="nameMsg" style="margin-left: 5px;font-size: 12px;">*</div></font></td>
					</tr>
					<tr>
						<td style="font-size: 12px;width:35%;" align="right"><font color="red">角色类型：</font></td>
						<td style="width:45%;" align="left">
						<select  name="rolerule" id="rolerule" style="width: 100%">
							<option value='-1'>请选择……</option>
						</select>
						</td>
						<td style="width:20%;" align="left"><font color="red"> <div id="typeMsg" style="margin-left: 5px;font-size: 12px;">*</div></font></td>
					</tr>
					
					<tr>
						<td style="height:30px;font-size: 12px;width:15%;" align="right" colspan="4"></td>
					</tr>
					<tr >
						<td></td>
						<td   style="height:22px;vertical-align: top;">
						<table style="width:100%"><tr><td style="width:20%" align="right">
						<input type="submit" value="保存" style="width: 60px; border-style: solid;border-width: 1px;border-color: #7f9db9;font-size: 9pt;background-color:#f1f5ff ;padding-top: 2px;" />
						</td><td align="right" style="width:20%">
						<input type="button" onclick="quitWin();" value="退出" style="width:60px; border-style: solid;border-width: 1px;border-color: #7f9db9;font-size: 9pt;background-color:#f1f5ff;padding-top: 2px; " />
						</td>
						<td style="width:20%"><input type="hidden" value="<%=request.getAttribute("roleid") %>" id="roleid" name="roleid" />  </td><td style="width:20%"></td><td style="width:20%"></td></tr></table>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
</body>
</html>